/*  This file is part of Real Time Digital Audio Processing library.
 *  Copyright (C) 2008 - Emilio Monti - emilmont@gmail.com
 *
 *  Real Time Digital Audio Processing library is free software: you can
 *  redistribute it and/or modify it under the terms of the GNU General
 *  Public License as published by the Free Software Foundation, either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  Real Time Digital Audio Processing library is distributed in the hope
 *  that it will be useful, but WITHOUT ANY WARRANTY; without even the
 *  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Real Time Audio Processing library.
 *  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef DTMF_H_
#define DTMF_H_

#include "Generate.h"

const char DTMF_KEYS[4][3] = {
        {'1','2','3'},
        {'4','5','6'},
        {'7','8','9'},
        {'*','0','#'},
};

const unsigned int DTMF_FREQ[7] = {697, 770, 852, 941, 1209, 1336, 1477};

class DTMF : public Module {
    public:
        DTMF(unsigned int sampleRate, float amp, char tone);
        void processSignal(float* signal, unsigned long length);
        virtual ~DTMF();

    private:
        Sine* s[2];
};

class DTMF_Detector : Module {
    public:
        DTMF_Detector(unsigned int sampleRate);
        void processSignal(float* signal, unsigned long length);
        char detected(void);
        virtual ~DTMF_Detector(){};

    private:
        unsigned int index;

        float r[7];    /* Results      */
        float c[7];    /* Coefficients */
        float d[7][3]; /* Delay Buffer */
};

#endif /*DTMF_H_*/
